<?php
namespace app\admin\model;

use think\Model;

class Member extends Model
{
    protected $table = 'user';
    protected $autoWriteTimestamp = 'datetime';


    public function getSexAttr($val)
    {
        switch ($val){
            case 1:
                return '男';
                break;
            case 2:
                return '女';
                break;
            default:
                return '未知';
                break;

        }
        
    }

    public function memberAddress(){

        return $this->hasMany('MemberAddress','user_id','id');

    }

    public function getAvatarAttr($val)
    {
        if (is_null($val)){

            return '/static/images/default_avatar.jpg';
        }

        return $val;
        
    }
}